/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ch.bbcnet.awesomeplayer;

import java.io.File;
import java.io.FileFilter;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileNameExtensionFilter;

/**
 *
 * @author esingn
 */
public class ImportMusic {
    Tags tag = Tags.getInstance();
    Table listenGUI;
    FileNameExtensionFilter filter = new FileNameExtensionFilter("MP3s", "mp3","wav","mid");
    public ImportMusic(Table a){
        this.listenGUI = a;
        JFileChooser jfc = new JFileChooser();
        jfc.setFileSelectionMode(JFileChooser.FILES_ONLY);
        jfc.setFileFilter(filter);
        jfc.setAcceptAllFileFilterUsed(false);
        jfc.setMultiSelectionEnabled(true);
        XML xml = XML.getInstance();
        jfc.showDialog(null,"Importieren");
        

       
        File[] x = jfc.getSelectedFiles();
        
        
        String[][] data = new String[x.length][5];
        
        for (int i=0;i<x.length;i++){
            data[i][0] = tag.getArtist(x[i]);
            data[i][1] = tag.getAlbum(x[i]);
            data[i][2] = tag.getTitel(x[i]);
            data[i][3] = tag.getGenre(x[i]);
            data[i][4] = x[i].getPath();        
        }
        
       xml.addToPlaylist("musik", data);
       listenGUI.setList(xml.getData("musik"),"musik");
       
        
        
    }
}
